package com.xuanmiao.smsback.service.platform.operator.impl;

import com.xuanmiao.smsback.domain.qo.SensitiveWordsInfoQO;
import com.panshi.hujin2.base.common.util.DozerUtils;
import com.panshi.hujin2.base.domain.page.Page;
import com.xuanmiao.smsback.dao.mapper.SensitiveWordsInfoMapper;
import com.xuanmiao.smsback.dao.model.SensitiveWordsInfoDO;

import com.xuanmiao.smsback.model.SensitiveWordsInfoBO;
import com.xuanmiao.smsback.service.platform.operator.SensitiveWordsInfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Collections;
import java.util.List;


@Service
public class SensitiveWordsInfoServiceImpl implements SensitiveWordsInfoService {
    @Autowired
    private SensitiveWordsInfoMapper sensitiveWordsInfoMapper;
    @Override
    public List<SensitiveWordsInfoBO> getList(SensitiveWordsInfoQO sensitiveWordsInfoQO) {
        if(sensitiveWordsInfoQO == null){
            sensitiveWordsInfoQO = new SensitiveWordsInfoQO();
        }
        //获取运营商数量
        Integer count = sensitiveWordsInfoMapper.count(sensitiveWordsInfoQO);
        Page page = sensitiveWordsInfoQO.getPage();
        //设置总记录数
        page.setTotalNumber(count);
        List<SensitiveWordsInfoDO> sensitiveWordsInfoDO = sensitiveWordsInfoMapper.querySensitiveWordsInfo(sensitiveWordsInfoQO);
        if(sensitiveWordsInfoDO!=null && sensitiveWordsInfoDO.size()>0){
            List<SensitiveWordsInfoBO> areContactInfoBO = DozerUtils.convertList(sensitiveWordsInfoDO, SensitiveWordsInfoBO.class);

            return areContactInfoBO;
                    //DozerUtils.convertList(areContactInfoMapper.query(areContactInfoQO),SensitiveWordsInfoBO.class);
        }
        return Collections.emptyList();


    }

    @Override
    public SensitiveWordsInfoBO getById(Integer id) {
        return DozerUtils.convert(sensitiveWordsInfoMapper.getById(id),SensitiveWordsInfoBO.class);
    }

    @Override
    public void update(SensitiveWordsInfoBO areContactInfoBO) {
        sensitiveWordsInfoMapper.update(DozerUtils.convert(areContactInfoBO,SensitiveWordsInfoDO.class));

    }


}
